package com.mnc.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.MapKey;
import javax.persistence.OneToMany;

@Entity
public class Article implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3567082963940458800L;
	//主键id
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int articleId;
	//标题
	@Column
	private String articleTitle;
	//内容
	@Column
	@Lob
	private String articleContent;
	//标签
	@Column
	private String articleLabels;
	//发表日期
	@Column
	private Date articleDate;
	//阅读数量
	@Column
	private int readCount;
	//热度
	@Column
	private int hotCount;
	//是否可见
	@Column
	private boolean articleView=true;
	//文章类型
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
	private ArticleType articleType;
	//作者
	@ManyToOne(cascade={CascadeType.REFRESH})
	private User writer;
	//评论
	@OneToMany(mappedBy="onArticle",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@MapKey(name="commentDate")
	private Set<ArticleComment> comments=new HashSet<ArticleComment>();
	//收藏夹
	@ManyToMany(mappedBy="collectArticles",cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
	private Set<UserCollect> collects=new HashSet<UserCollect>();
	
	public int getArticleId() {
		return articleId;
	}
	public void setArticleId(int articleId) {
		this.articleId = articleId;
	}
	public String getArticleTitle() {
		return articleTitle;
	}
	public void setArticleTitle(String articleTitle) {
		this.articleTitle = articleTitle;
	}
	public String getArticleContent() {
		return articleContent;
	}
	public void setArticleContent(String articleContent) {
		this.articleContent = articleContent;
	}
	public String getArticleLabels() {
		return articleLabels;
	}
	public void setArticleLabels(String articleLabels) {
		this.articleLabels = articleLabels;
	}
	public Date getArticleDate() {
		return articleDate;
	}
	public void setArticleDate(Date articleDate) {
		this.articleDate = articleDate;
	}
	public int getReadCount() {
		return readCount;
	}
	public void setReadCount(int readCount) {
		this.readCount = readCount;
	}
	public int getHotCount() {
		return hotCount;
	}
	public void setHotCount(int hotCount) {
		this.hotCount = hotCount;
	}
	public ArticleType getArticleType() {
		return articleType;
	}
	public void setArticleType(ArticleType articleType) {
		this.articleType = articleType;
	}
	public User getWriter() {
		return writer;
	}
	public void setWriter(User writer) {
		this.writer = writer;
	}
	public Set<ArticleComment> getComments() {
		return comments;
	}
	public void setComments(Set<ArticleComment> comments) {
		this.comments = comments;
	}
	public Set<UserCollect> getCollects() {
		return collects;
	}
	public void setCollects(Set<UserCollect> collects) {
		this.collects = collects;
	}
	public boolean isArticleView() {
		return articleView;
	}
	public void setArticleView(boolean articleView) {
		this.articleView = articleView;
	}
	
	
}
